# -*- coding: utf-8 -*-

import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *


class MainWindow(QWidget):

    def __init__(self, parent=None):
        super(MainWindow, self).__init__(parent=parent)

        layout = QHBoxLayout()

        self.btn1 = QRadioButton("Button1")
        self.btn1.setChecked(True)
        self.btn1.toggled.connect(lambda : self.btnstate(self.btn1))
        layout.addWidget(self.btn1)

        self.btn2 = QRadioButton("Button2")
        self.btn2.toggled.connect(lambda : self.btnstate(self.btn2))
        layout.addWidget(self.btn2)

        self.setLayout(layout)
        self.setWindowTitle("RadioButton Demo")

    def btnstate(self, btn):
        if btn.isChecked():
            print("%s is selected" % btn.text())
        else:
            print("%s is deselected" % btn.text())


if __name__ == '__main__':
    app = QApplication(sys.argv)
    win = MainWindow()
    win.show()
    sys.exit(app.exec())